package org.gui;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Data structure 
 *
 */
public class Task {
	/**
	 *  TaskID
	 */
	private int id;
	
	/**
	 *  UNIX-Timestamp
	 */
	private long timestamp;
	
	/**
	 *  Status
	 *  1 - not finished
	 *  2 - in progress
	 *  3 - finished
	 */
	private String status;
	
	/**
	 * Name of the NXT-Action
	 * e.g. MOVE, LIFT, PULL
	 */
	private String action;
	
	/**
	 * Row name
	 * e.g. 1, 2, 3, 4, 5, ...
	 */
	private String row;
	
	/**
	 * Column name
	 * e.g. A, B, C, D, E, ...
	 */
	private String col;

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	/**
	 * 
	 */
	public Task()
	{
		
	}
	
	/**
	 * 
	 * @param id
	 * @param action
	 * @param col
	 * @param row
	 * @param status
	 * @param timestamp
	 */
	public Task(int id, String action, String col, String row, String status, long timestamp)
	{
		this.setId(id);
		this.setAction(action);
		this.setCol(col);
		this.setRow(row);
		this.setStatus(status);
		this.setTimestamp(timestamp);
	}
	
	public Task(String action, String col, String row)
	{
		this.setAction(action);
		this.setCol(col);
		this.setRow(row);
	}
	
	public Task(int id, String status, long timestamp)
	{
		this.setId(id);
		this.setStatus(status);
		this.setTimestamp(timestamp);
	}
	
	private String timestampToDate(long timestamp)
	{
		Date date = new Date(timestamp);
		SimpleDateFormat sDate = new SimpleDateFormat("dd.MM.yyyy HH:mm");
		
		return sDate.format(date);
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param timestamp the timestamp to set
	 */
	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	/**
	 * @return the timestamp
	 */
	public String getTime() {
		return timestampToDate(this.timestamp);
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param action the action to set
	 */
	public void setAction(String action) {
		this.action = action;
	}

	/**
	 * @return the action
	 */
	public String getAction() {
		return action;
	}

	/**
	 * @param row the row to set
	 */
	public void setRow(String row) {
		this.row = row;
	}

	/**
	 * @return the row
	 */
	public String getRow() {
		return row;
	}

	/**
	 * @param col the col to set
	 */
	public void setCol(String col) {
		this.col = col;
	}

	/**
	 * @return the col
	 */
	public String getCol() {
		return col;
	}
}
